// 用户相关API
import request from '../utils/http'; // 假设request是封装的axios实例

// 获取博客文章
export const getArticles = (page: number, pageSize: number, keyword?: string) => {
  const params: any = { page, pageSize };
  if (keyword) params.keyword = keyword;
  return request.get(`/blog/articles`, { params });
};

// 新增博客文章
export const addArticle = (article: { title: string; category: string; tags: string; content: string; userId: string }) => {
  return request.post('/blog/articles', article);
};

// 修改博客文章
export const updateArticle = (articleId: string, article: { title: string; category: string; tags: string; content: string; userId: string }) => {
  return request.put(`/blog/articles/${articleId}`, article);
};

// 获取单篇文章
export const getArticleDetail = (articleId: string) => {
  return request.get(`/blog/articles/${articleId}`);
};

// 删除文章
export const deleteArticle = (articleId: string) => {
  return request.delete(`/blog/articles/${articleId}`);
};
